package com.yunfeisoft.business.dao.impl;

import com.yunfeisoft.business.dao.inter.ElderHealthEvaluationDao;
import com.yunfeisoft.business.model.ElderHealthEvaluation;
import com.yunfeisoft.common.base.BaseDaoImpl;
import com.yunfeisoft.common.sql.builder.WhereBuilder;
import com.yunfeisoft.common.utils.Page;
import org.springframework.stereotype.Repository;
import org.springframework.util.ObjectUtils;

import java.util.List;
import java.util.Map;

/**
 * ClassName: ElderHealthEvaluationDaoImpl
 * Description: 健康评价与指导从表Dao实现
 * Author: Jackie liu
 * Date: 2020-04-04
 */
@Repository
public class ElderHealthEvaluationDaoImpl extends BaseDaoImpl<ElderHealthEvaluation, String> implements ElderHealthEvaluationDao {

    @Override
    public Page<ElderHealthEvaluation> queryPage(Map<String, Object> params) {
        WhereBuilder wb = new WhereBuilder();
        if (params != null) {
            initPageParam(wb, params);
        }
        return queryPage(wb);
    }

    @Override
    public ElderHealthEvaluation getByHealthId(String elderHealthId) {
        WhereBuilder wb = new WhereBuilder();
        wb.andEquals("elderHealthId", elderHealthId);
        List<ElderHealthEvaluation> evaluationList = query(wb);
        if (ObjectUtils.isEmpty(evaluationList)) {
            return null;
        }
        return evaluationList.get(0);
    }

    @Override
    public void deleteByHealthId(String elderHealthId) {
        WhereBuilder wb = new WhereBuilder();
        wb.andEquals("elderHealthId", elderHealthId);
        deleteByCondition(wb);
    }
}